﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HFK.DxFluentUIGUITest.Dummy.DataObjects;
using HFK.DxFluentUI.HorizontalGrid;

namespace HFK.DxFluentUIGUITest.Dummy
{
  public class HorizontalGridFullFeatured : HorizontalGridControlBase
  {
    public HorizontalGridFullFeatured()
    {
      View<SomeData>("View1",
        v1 =>
        {
          v1.AddColumn("Column1");
          v1.AddColumn("Column2").BindToProperty(d => d.IntValue).And().WithSorting().NotAllowed();
          v1.AddColumn("Column3").BindToProperty(d => d.IntValue).And().WithSorting().Allowed().And().WithEditing().AllowedUsing().Values(new int[] { 1, 1, 2, 3, 5, 8 });
          v1.AddColumn("Column4").BindToProperty(d => d.StringValue).And().WithEditing().AllowedUsing()
            .Objects<SomeSubdata>(new SomeSubdata[]{
              new SomeSubdata(){ Submember = "S1", Textmember = "TEXT1", Prop1 = "P11", Prop2 = "P12" },
              new SomeSubdata(){ Submember = "S2", Textmember = "TEXT2", Prop1 = "P21", Prop2 = "P22" },
              new SomeSubdata(){ Submember = "S3", Textmember = "TEXT3", Prop1 = "P31", Prop2 = "P32" }
            })
            .InDropdownGridEditor(
              de =>
              {
                de.DisplayProperty(d => d.Textmember);
                de.AssignValue().FromProperty(d => d.Submember);
                de.AddColumn("Cap1", d => d.Prop1);
                de.AddColumn("Cap2", d => d.Prop2);
              });
          v1.AddColumn("Column5").BindToProperty(d => d.Subdata).And().WithEditing().AllowedUsing()
            .Objects<SomeSubdata>(new SomeSubdata[]{
              new SomeSubdata(){ Submember = "S1", Textmember = "TEXT1" },
              new SomeSubdata(){ Submember = "S2", Textmember = "TEXT2" },
              new SomeSubdata(){ Submember = "S3", Textmember = "TEXT3" }
            })
            .InDropdownBoxEditor(
              de =>
              {
                de.DisplayProperty(d => d.Submember);
                de.AssignValue().FromObject();
              });
          v1.AddColumn("Column6").BindToProperty(d => d.Subdata.Submember);
          v1.AddDetailView<SomeSubdata>("DetailView1",
            dv1 =>
            {
              dv1.OptimizeColumnWidthForText().WithEditing().Allowed();
              dv1.OptimizeColumnWidthForText().WithGrouping().Allowed();
              dv1.BindToCollection(d => d.SubdataList);
              dv1.AddColumn("Column11");
              dv1.AddColumn("Column12").BindToProperty(d => d.Submember).And().WithFiltering().Allowed();
            });
          v1.AddDetailView<SingleHopClass>("DetailView2",
            dv2 =>
            {
              dv2.OptimizeColumnWidthForView().WithEditing().NotAllowed();
              dv2.OptimizeColumnWidthForText().WithGrouping().NotAllowed();
              dv2.BindToCollection(d => d.ComplexSubdataList);
              dv2.AddColumn("Column21").BindToProperty(d => d.StringValue).And().WithFiltering().Allowed();
              dv2.AddColumn("Column22").BindToProperty(d => d.DhcProperty.ThcProperty.StringProperty).And().WithFiltering().NotAllowed();
              dv2.AddDetailView<DualHopClass>("DetailView21",
                dv21 => 
                {
                  dv21.BindToCollection(d => d.DhcList);
                  dv21.AddColumn("Column211", d => d.ThcProperty.StringProperty);
                });
            });
        });
    }
  }
}
